package edu.bit.water.controller;

import edu.bit.water.entity.CleanProduct;
import edu.bit.water.entity.EntityCompany;
import edu.bit.water.service.LabelEntityWaterBalaService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Controller
@RequestMapping("/label_entity_water_bala")
public class LabelEntityWaterBalaController {
    @Autowired
    LabelEntityWaterBalaService labelEntityWaterBalaService;

    @RequestMapping("/select")
    @ResponseBody
    public Map<String, Object> select(int company_id){
        Map<String, Object> modelMap = new HashMap<>();
        List<EntityCompany> list = labelEntityWaterBalaService.select(company_id);
        List<EntityCompany> newlist = labelEntityWaterBalaService.select(company_id);
        for(int i =0;i<list.size();i++)
        {
            String tablename = list.get(i).getTableName();
            if(tablename.equals("企业取水水源表")){
                newlist.set(0, list.get(i));
            }
            if(tablename.equals("企业年用水表")){
                newlist.set(1, list.get(i));
            }
            if(tablename.equals("企业生产情况统计表")){
                newlist.set(2, list.get(i));
            }
            if(tablename.equals("全厂计量水表配备情况表")){
                newlist.set(3, list.get(i));
            }
            if(tablename.equals("用水单元水平衡测试表")){
                newlist.set(4, list.get(i));
            }
            if(tablename.equals("企业水平衡测试统计表")){
                newlist.set(5, list.get(i));
            }
            if(tablename.equals("企业用水分析表")){
                newlist.set(6, list.get(i));
            }
            if(tablename.equals("水平衡图")){
                newlist.set(7, list.get(i));
            }
        }
        modelMap.put("status", "success");
        modelMap.put("rows", newlist);
        return modelMap;
    }
}
